package com.fc.persistence;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

import com.fc.commons.AnnotationUtility;
import com.fc.persistence.anno.ShardEntity;
import com.fc.persistence.cache.redis.SharedJedisFacade;

public class EntityNameRegister implements BeanPostProcessor {

	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		Class<?> clazz = AnnotationUtility.findAnnotationDeclaringClassAndInterface(ShardEntity.class, bean.getClass());
		if (clazz == null) {
			return bean;
		}
		ShardEntity entity = clazz.getAnnotation(ShardEntity.class);
		if (entity != null) {

		}
		SharedJedisFacade.saddProxy(GlobalPersistenceConst.ENTITY_NAME, clazz.getName());
		return bean;
	}

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		return null;
	}
}
